﻿using Newtonsoft.Json;

namespace Common.Base.Result
{
    /// <summary>
    /// 返回结果
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ResultData<T>
    {
        /// <summary>
        /// 状态码
        /// </summary>
        public int Code { get; set; } = 200;

        /// <summary>
        /// 消息
        /// </summary>
        public string Msg { get; set; } = "操作成功";

        /// <summary>
        /// 数据
        /// </summary>
        public T Data { get; set; }

        public override string ToString()
        {
            return Code != 200 ? $"[error msg]:{Msg}" : $"[result]:{JsonConvert.SerializeObject(Data)}";
        }
    }
}